﻿@using Pyramid.Models
@using Pyramid.Mvc.Html
@model  IEnumerable<Article>
@{
	var vm = (ArticleListViewModel)ViewBag.ViewModel;
}

@using (Html.BeginForm("List", "Staff", FormMethod.Post, new {id = "pagerForm"}))
{
	<input type="hidden" name="pageNum" value="1" />
	<input type="hidden" name="numPerPage" value="${model.numPerPage}" />
}

<div class="pageHeader">
	@using (Html.BeginForm("List", "Article", FormMethod.Post, new {onsubmit = "return navTabSearch(this);"}))
	{
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>关键词：<input type="text" name="Keywords" rel="pagerForm" value="@vm.QueryModel.Keywords" /></td>
					<td>
						@Html.DropDownList("ChannelId", vm.Channels, new {@class = "combox", rel = "pagerForm"})
					</td>
				</tr>
			</table>
		</div>
		<div class="subBar">
			<table>
				<tr>
					<td>更新时间从 
						<input type="text" name="CreateTimeFrom" class="date" readonly="readonly" rel="pagerForm" value="@Html.DateString(vm.QueryModel.CreateTimeFrom)" />
						至 
						<input type="text" name="CreateTimeTo" class="date" readonly="readonly" rel="pagerForm"  value="@Html.DateString(vm.QueryModel.CreateTimeTo)"/>
					</td>
					<td>&nbsp;&nbsp;</td>
					<td>
						<div class="buttonActive">
							<div class="buttonContent">
								<button type="submit">查询</button>
							</div>
						</div>
					</td>
				</tr>
			</table>
		</div>
	}
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" href="@Url.Action("Create")" target="navTab" rel="tab_article_edit"><span>添加文章</span></a></li>
			<li><a class="edit" href="@Url.Action("Edit", new { id = "{id}" })" target="navTab" rel="tab_article_edit"><span>编辑文章</span></a></li>
			<li><a class="delete" href="@Url.Action("Delete", new { id = "{id}" })" target="ajaxTodo" title="确定要删除吗？"><span>删除</span></a></li>
			<li><a class="icon" href="@Url.Action("CancelPublish", new { id = "{id}" })" target="ajaxTodo" title="确定要取消发布吗？"><span>取消发布</span></a></li>
			<li><a class="icon" href="@Url.Action("RePublish", new { id = "{id}" })" target="ajaxTodo" title="确定要重新发布吗？"><span>重新发布</span></a></li>
		</ul>
	</div>
	<table class="table" width="100%" layouth="138">
		<thead>
			<tr>
				<th width="80">@Html.DisplayNameFor(m=>m.Id)</th>
				<th>@Html.DisplayNameFor(m=>m.Title)</th>
				<th width="120">@Html.DisplayNameFor(m=>m.ChannelId)</th>
				<th width="200">@Html.DisplayNameFor(m=>m.CreateTime)</th>
				<th width="80">@Html.DisplayNameFor(m=>m.CreateUserId)</th>
				<th width="200">@Html.DisplayNameFor(m=>m.EditTime)</th>
				<th width="80">@Html.DisplayNameFor(m=>m.EditUserId)</th>
			</tr>
		</thead>
		<tbody>
			@foreach (var s in Model)
			{
				<tr target="id" rel="@s.Id">
					<td>@s.Id</td>
					<td>@s.Title</td>
					<td>@s.Channel.Name</td>
					<td>@s.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
					<td>@s.CreateUserId</td>
					<td>@s.EditTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
					<td>@s.EditUserId</td>
				</tr>
			}
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20">20</option>
				<option value="50">50</option>
				<option value="100">100</option>
				<option value="200">200</option>
			</select>
			<span>条，共 @vm.TotalCount 条</span>
		</div>
		<div class="pagination" targettype="navTab" totalcount="@vm.TotalCount" numperpage="@vm.PageSize" pagenumshown="10" currentpage="@vm.CurrentPageIndex"></div>
	</div>
</div>
